package com.example.room.viewModel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.room.StudentRepository;
import com.example.room.entity.Student;

import java.util.List;

public class StudentViewModel extends AndroidViewModel {

    private StudentRepository repository;

    public StudentViewModel(@NonNull Application application) {
        super(application);
        repository = new StudentRepository(application);
    }

    public void insert(Student... students) {
        repository.insertStudent(students);
    }

    public void delete(Student... students) {
        repository.deleteStudent(students);
    }

    public void update(Student... students) {
        repository.updateStudent(students);
    }

    public void deleteAll() {
        repository.deleteAllStudent();
    }

    public LiveData<List<Student>> queryAll() {
        return repository.queryAllStudent();
    }

}
